<%@ page import="java.io.*, java.text.*, java.util.Date, java.sql.*, javax.servlet.*, javax.servlet.http.*, java.util.*" %>

<%!
public void check(String [] arr)
{
	for(int i=0;i<arr.length;i++)
	{
		while(arr[i] != null && arr[i].indexOf("\n") != -1)
		{
			arr[i] = arr[i].substring(0,arr[i].indexOf("\n")-1) + "<br/>" + arr[i].substring(arr[i].indexOf("\n")+1,arr[i].length());
		}
	}
}
%>

<%
String usernameSC = (String) session.getAttribute("session_name");
String typeSC = (String) session.getAttribute("type");
	{
		String pid = request.getParameter("pId");
		String driver ="com.mysql.jdbc.Driver";
		String url = "jdbc:mysql://localhost:3306/projects";
		String username = "ia";
		String password = "123";
		String [] proj = new String[10];
		int size = 0;
		try
		{
			Class.forName(driver).newInstance();
			Connection connection = DriverManager.getConnection(url, username, password);
			Statement statement = connection.createStatement();
			Statement statement1 = connection.createStatement();
		
			ResultSet rs = null;
			ResultSet rs1 = null;
	
			String query = "select count(*) from projects where id="+pid;
			String query1 = "select * from projects where id="+pid;
			rs = statement.executeQuery(query);
			if(rs.next())
			{
				size = rs.getInt(1);
			}
			
			rs1 = statement1.executeQuery(query1);
			
			if(rs1.next())
			{
				proj[0] = rs1.getString("Title");
				proj[1] = rs1.getString("description");
				proj[2] = rs1.getString("Project_Objectives");
				proj[3] = rs1.getString("Required_Background");
				proj[4] = rs1.getString("Tools_Needed");
				proj[5] = rs1.getString("Difficulty_Level");
				proj[6] = rs1.getString("Project_Type");
				proj[7] = rs1.getString("Project_Keywords");
				proj[8] = rs1.getString("Expected_Results");
				proj[9] = rs1.getString("Additional_Comments");
			}
			
			check(proj);

			out.println("<script type='text/javascript'>");
			out.println("var dproj = new Array();"); 
			out.println("dproj[0] = '"+ proj[0]+"'");
			out.println("dproj[1] = '"+ proj[1]+"'");
			out.println("dproj[2] = '"+ proj[2]+"'");
			out.println("dproj[3] = '"+ proj[3]+"'");
			out.println("dproj[4] = '"+ proj[4]+"'");
			out.println("dproj[5] = '"+ proj[5]+"'");
			out.println("dproj[6] = '"+ proj[6]+"'");
			out.println("dproj[7] = '"+ proj[7]+"'");
			out.println("dproj[8] = '"+ proj[8]+"'");
			out.println("dproj[9] = '"+ proj[9]+"'");
			out.println("</script>");
			
	connection.close();
		
		
%>


<html>
	<head>
	
	</head>
<body>
	<script type="text/javascript">
		
		document.write("<table style='width:100%; height:100%'><tr><td><h4>Title</h4></td><td>"+dproj[0]);
		document.write("description");
				/*proj[2] = rs1.getString("Project_Objectives");
				proj[3] = rs1.getString("Required_Background");
				proj[4] = rs1.getString("Tools_Needed");
				proj[5] = rs1.getString("Difficulty_Level");
				proj[6] = rs1.getString("Project_Type");
				proj[7] = rs1.getString("Project_Keywords");
				proj[8] = rs1.getString("Expected_Results");
				proj[9] = rs1.getString("Additional_Comments");
		
		
		*/
		
		
	</script>	
</body>
</html>


<%
}catch(ClassNotFoundException cnfe)
		{
			out.println("<br>Couldn't find class file" + cnfe); 
		}catch(SQLException sqle)
		{
			out.println("<br>SQL Exception: " + sqle);
		}catch(InstantiationException ie)
		{
			out.println("<br>Instant exception : " + ie);
		}catch(IllegalAccessException iae)
		{
			out.println("<br>Illegal access exception : " + iae);
		}
    }
%>